IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[Customers_CustomerTypes]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customers]'))
ALTER TABLE [dbo].[Customers] DROP CONSTRAINT [Customers_CustomerTypes]
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__Customers__Custo__08EA5793]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customers] DROP CONSTRAINT [DF__Customers__Custo__08EA5793]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND type in (N'U'))
DROP TABLE [dbo].[Customers]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customers](
	[Id] [uniqueidentifier] NOT NULL,
	[CompanyName] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[IsActive] [varbinary](max) NOT NULL,
	[OriginationDate] [datetime] NULL,
	[CustomerTypeId] [int] NOT NULL,
 CONSTRAINT [PK_CUSTOMERS_ID] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Customers]  WITH CHECK ADD  CONSTRAINT [Customers_CustomerTypes] FOREIGN KEY([CustomerTypeId])
REFERENCES [CustomerTypes] ([Id])
GO
ALTER TABLE [dbo].[Customers] CHECK CONSTRAINT [Customers_CustomerTypes]
GO
ALTER TABLE [dbo].[Customers] ADD  DEFAULT ((1)) FOR [CustomerTypeId]
GO
